// COMServer.h: Deklaration von CCOMServer
#ifndef _USRDLL
#pragma once
#include "resources\resource.h"       // Hauptsymbole
#include <atlcom.h>
#include <atlbase.h>


#include "COMServer_i.h"






// CCOMServer

class CCOMServer : public ICOMServer
{
public:
	CCOMServer();
	//~CCOMServer();

	// IUnknown implementation
	virtual HRESULT __stdcall QueryInterface(const IID& iid, void** ppv) ;
	virtual ULONG __stdcall AddRef() ;
	virtual ULONG __stdcall Release() ;

	//IDispatch implementation
	virtual HRESULT __stdcall GetTypeInfoCount(UINT* pctinfo);
	virtual HRESULT __stdcall GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo);
	virtual HRESULT __stdcall GetIDsOfNames(REFIID riid, 
		LPOLESTR* rgszNames, UINT cNames,
		LCID lcid, DISPID* rgdispid);
	virtual HRESULT __stdcall Invoke(DISPID dispidMember, REFIID riid,
		LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
		EXCEPINFO* pexcepinfo, UINT* puArgErr);


	// ICOMServer implementation
	virtual HRESULT __stdcall NewThread(/*in,optional*/VARIANT script,/*in,optional*/VARIANT params,/*in,optional*/VARIANT title,/*out*/unsigned int* ThreadID);
	virtual HRESULT __stdcall ahkPause(/*in*/ VARIANT aThreadID,/*in,optional*/VARIANT aChangeTo,/*out*/int* paused);
	virtual HRESULT __stdcall ahkReady(/*in*/ VARIANT aThreadID,/*out*/int* ready);
	virtual HRESULT __stdcall ahkFindLabel(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT aLabelName,/*[out, retval]*/ UINT_PTR* pLabel);
	virtual HRESULT __stdcall ahkgetvar(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT name,/*[in,optional]*/ VARIANT getVar,/*[out, retval]*/ VARIANT* returnVal);
	virtual HRESULT __stdcall ahkassign(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT name,/*[in,optional]*/ VARIANT value,/*[out, retval]*/ int* success);
	virtual HRESULT __stdcall ahkExecuteLine(/*in*/ VARIANT aThreadID,/*[in,optional]*/ VARIANT line,/*[in,optional]*/ VARIANT aMode,/*[in,optional]*/ VARIANT wait,/*[out, retval]*/ UINT_PTR* pLine);
	virtual HRESULT __stdcall ahkLabel(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT aLabelName,/*[in,optional]*/ VARIANT nowait,/*[out, retval]*/ int* success);
	virtual HRESULT __stdcall ahkFindFunc(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT FuncName,/*[out, retval]*/ UINT_PTR* pFunc);
	virtual HRESULT __stdcall ahkFunction(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT FuncName,/*[in,optional]*/ VARIANT param1,/*[in,optional]*/ VARIANT param2,/*[in,optional]*/ VARIANT param3,/*[in,optional]*/ VARIANT param4,/*[in,optional]*/ VARIANT param5,/*[in,optional]*/ VARIANT param6,/*[in,optional]*/ VARIANT param7,/*[in,optional]*/ VARIANT param8,/*[in,optional]*/ VARIANT param9,/*[in,optional]*/ VARIANT param10,/*[out, retval]*/ VARIANT* returnVal);
	virtual HRESULT __stdcall ahkPostFunction(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT FuncName,/*[in,optional]*/ VARIANT param1,/*[in,optional]*/ VARIANT param2,/*[in,optional]*/ VARIANT param3,/*[in,optional]*/ VARIANT param4,/*[in,optional]*/ VARIANT param5,/*[in,optional]*/ VARIANT param6,/*[in,optional]*/ VARIANT param7,/*[in,optional]*/ VARIANT param8,/*[in,optional]*/ VARIANT param9,/*[in,optional]*/ VARIANT param10,/*[out, retval]*/ VARIANT* returnVal);
	virtual HRESULT __stdcall addScript(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT script,/*[in,optional]*/ VARIANT waitexecute,/*[out, retval]*/ UINT_PTR* success);
	virtual HRESULT __stdcall ahkExec(/*in*/ VARIANT aThreadID,/*[in]*/ VARIANT script,  /*[out, retval]*/ int* success);
};

//private:
	//HRESULT LoadTypeInfo(ITypeInfo** pptinfo, const CLSID& libid, const CLSID& iid, LCID lcid);
	// Reference count
	//long		m_cRef;
	//LPTYPEINFO	m_ptinfo; // pointer to type-library
OBJECT_ENTRY_AUTO(__uuidof(AuotHotkey2COMServer), CCOMServer)
#endif